require_relative 'boot'

require 'rails/all'

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

module YangyiWeb
  class Application < Rails::Application
    config.time_zone = 'Beijing'
    config.active_record.default_timezone = :local
    config.x.authed_api_user_agent = "YY_web"

    config.i18n.default_locale = 'zh-CN'
    #config.autoload_paths << Rails.root.join('app/services')
    config.encoding = 'utf-8'
    #config.action_view.embed_authenticity_token_in_remote_forms = true
    #config.eager_load_paths << "#{Rails.root}/lib"
    #config.autoload_paths += Dir[Rails.root.join('app', 'models', '{*/}')]
    config.autoload_paths += Dir["#{config.root}/lib/**/"]

    config.active_record.time_zone_aware_types = [:datetime, :time]

    if defined?(Dalli)
      dalli_config = YAML.load_file(Rails.root.join('config/dalli.yml'))[Rails.env]
      memcached_hosts = dalli_config['servers']
      config.cache_store = :dalli_store, *memcached_hosts, dalli_config["options"]
    end
    $memory_store = ActiveSupport::Cache::MemoryStore.new

    #webpack
    config.webpack = {
      :use_manifest => false,
      :asset_manifest => {},
      :common_manifest => {},
    }

    config.generators do |g|
      g.orm             :active_record
      g.template_engine :erb
      g.test_framework  nil
      g.stylesheets     false
      g.javascripts     false
    end
  end
end
